Zookeepr Installation Instructions
==================================

External dependencies
---------------------

 * libpq-dev
 * libpython-dev
 * libxslt1-dev
 * libxml2-dev
 * postgresql


Creating a development environment
----------------------------------

1. Create a postgresql database for your ZooKeepr instance.

        sudo -u postgres createuser --no-createdb --no-createrole --no-superuser zookeepr
        sudo -u postgres createdb -O zookeepr zk
        sudo -u postgres psql --command "ALTER USER zookeepr with PASSWORD 'zookeepr'"

2. Create a virtualenv for your ZooKeepr instance.

        \# using only virtualenv
        virtualenv env --no-site-packages
        . ./env/bin/activate

        \# using virtualenwrapper
        mkvirtualenv zookeepr # --no-site-packages is default
        workon zookeepr

3. Configure.

        cp zkpylons/config/lca_info.py.sample zkpylons/config/lca_info.py
        cp development.ini.sample development.ini
        python setup.py develop

    Edit development.ini to set sqlachemy.url to match your postgresql database.
    Note: You must set sqlachemy.url in both the [app:main] and [alembic] sections

4. Populate database. Run alembic to create and populate the initial database.

        alembic --config development.ini upgrade head

        WARNING: On a vanilla trunk this does not currently work but there
        is a workaround:

            * Zookeepr is using alembic in a rather unusual way, which leads to
            problems. James has a work-around for this, but it is not currently in
            master and should never be committed to master. The work-around can be
            cherry-picked, commit c3812eb0 from
            https://github.com/iseppi/zookeepr.git on the nasty-db-import-fix
            branch.

            git remote add alembicfix https://github.com/iseppi/zookeepr.git
            git fetch alembicfix nasty-db-import-fix
            git cherry-pick a641643758d88238e4ada43f873d7b021238debe
            alembic --config development.ini upgrade head
            git reset --hard HEAD^

            To verify the fix, use the alembic history command and check that the
            head revision is "This revision is a lie and should always be head".
            $ alembic --config development.ini history

5. Run development server.

        pserve --reload development.ini

6. The default admin account is:
        email: admin@zookeepr.org
        password: password
